home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmOLE
- BackColor = &H00C0C0C0&
- Caption = "OLE Automation"
- ClientHeight = 4725
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 6555
- ClipControls = 0 'False
- Height = 5130
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 4725
- ScaleWidth = 6555
- Top = 1140
- Width = 6675
- Begin Frame Frame4
- BackColor = &H00C0C0C0&
- Caption = "Object Info"
- ClipControls = 0 'False
- Height = 2010
- Left = 4545
- TabIndex = 17
- Top = 105
- Width = 1935
- Begin CommandButton cmdLoadExcel
- Caption = "Show Excel"
- Enabled = 0 'False
- Height = 375
- Index = 4
- Left = 120
- TabIndex = 10
- Top = 930
- Width = 1700
- End
- Begin CommandButton cmdLoadExcel
- Caption = "Is Excel Running?"
- Height = 375
- Index = 3
- Left = 120
- TabIndex = 9
- Top = 405
- Width = 1700
- End
- End
- Begin Frame Frame2
- BackColor = &H00C0C0C0&
- Caption = "In Place Activation"
- ClipControls = 0 'False
- Height = 2310
- Left = 105
- TabIndex = 15
- Top = 2295
- Width = 6360
- Begin Frame Frame3
- BackColor = &H00C0C0C0&
- Caption = "MemStorage"
- Height = 975
- Left = 120
- TabIndex = 5
- Top = 1155
- Width = 1665
- Begin OptionButton optMem
- BackColor = &H00C0C0C0&
- Caption = "Disk"
- Height = 270
- Index = 1
- Left = 150
- TabIndex = 7
- Top = 630
- Width = 1215
- End
- Begin OptionButton optMem
- BackColor = &H00C0C0C0&
- Caption = "RAM"
- Height = 270
- Index = 0
- Left = 150
- TabIndex = 6
- Top = 330
- Value = -1 'True
- Width = 1215
- End
- End
- Begin CommandButton cmdOLE2
- Caption = "Activate"
- Height = 375
- Left = 120
- TabIndex = 4
- Top = 570
- Width = 1710
- End
- Begin OLE OLE1
- BorderStyle = 0 'None
- Class = "Excel.Sheet.5"
- fFFHk = -1 'True
- Height = 1575
- Left = 2760
- OleObjectBlob = FRMOLE.FRX:0000
- SizeMode = 1 'Stretch
- TabIndex = 8
- Top = 570
- Width = 3420
- End
- Begin Label lblResult
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "00.00 - sec."
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 240
- Index = 3
- Left = 4095
- TabIndex = 16
- Top = 240
- Width = 1185
- End
- End
- Begin Frame Frame1
- BackColor = &H00C0C0C0&
- Caption = "OLE Automation"
- ClipControls = 0 'False
- Height = 2010
- Left = 105
- TabIndex = 11
- Top = 105
- Width = 4320
- Begin CheckBox chkVisible
- BackColor = &H00C0C0C0&
- Caption = "Visible"
- Height = 495
- Left = 1980
- TabIndex = 1
- Top = 330
- Width = 900
- End
- Begin CommandButton cmdLoadExcel
- Caption = "Close Object"
- Height = 375
- Index = 2
- Left = 120
- TabIndex = 3
- Top = 1480
- Width = 1710
- End
- Begin CommandButton cmdLoadExcel
- Caption = "Shell"
- Height = 375
- Index = 1
- Left = 120
- TabIndex = 2
- Top = 930
- Width = 1710
- End
- Begin CommandButton cmdLoadExcel
- Caption = "CreateObject"
- Height = 375
- Index = 0
- Left = 120
- TabIndex = 0
- Top = 405
- Width = 1710
- End
- Begin Label lblResult
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "00.00 - sec."
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 240
- Index = 2
- Left = 3000
- TabIndex = 12
- Top = 1500
- Width = 1185
- End
- Begin Label lblResult
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "00.00 - sec."
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 240
- Index = 1
- Left = 3000
- TabIndex = 13
- Top = 1005
- Width = 1185
- End
- Begin Label lblResult
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "00.00 - sec."
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 240
- Index = 0
- Left = 3000
- TabIndex = 14
- Top = 510
- Width = 1185
- End
- End
- Dim xlSheet As Object
- Dim ixlHwnd As Integer
- Dim lMsgRslt As Long
- Sub cmdLoadExcel_Click (Index As Integer)
- Select Case Index
- Case 0 ' Create Object
- Screen.MousePointer = 11
- Start = Timer
- Set xlSheet = CreateObject("Excel.Sheet")
- DoEvents
-
- If chkVisible.Value Then
- xlSheet.Application.Visible = True
- End If
-
- Finish = Timer
- Screen.MousePointer = 0
- lblResult(Index) = Format$(Finish - Start, "##.##") & " secs."
- Case 1 ' Shell Excel
- Screen.MousePointer = 11
- Start = Timer
- iRetVal% = Shell("EXCEL.EXE", 1) ' Minimized without focus.
- DoEvents
- Finish = Timer
- Screen.MousePointer = 0
- lblResult(Index) = Format$(Finish - Start, "##.##") & " secs."
- Case 2 ' Close Objects
- On Error Resume Next
-
- If xlSheet.Application.Visible Then
- xlSheet.Application.Quit
- Else
- Set xlSheet = Nothing
- End If
- Case 3 ' Is Excel Running
- ixlHwnd = FindWindow("XLMAIN", 0&)
- If ixlHwnd <> 0 Then
- cmdLoadExcel(4).Enabled = True
- MsgBox "Excel is running. It's handle is " & Str$(ixlHwnd), 64, "Excel Status"
- Else
- cmdLoadExcel(4).Enabled = False
- MsgBox "Excel is NOT running.", 64, "Excel Status"
- End If
- Case 4 ' Show Excel
- lMsgRslt = SendMessage(ixlHwnd, WM_SYSCOMMAND, SC_RESTORE, 0)
- End Select
- End Sub
- Sub cmdOLE2_Click ()
- If optMem(0).Value Then
- OLE1.MiscFlags = 1
- Else
- OLE1.MiscFlags = 0
- End If
- Start = Timer
- OLE1.Action = 7 'Activate the object
- ' DoEvents
- Finish = Timer
- lblResult(3) = Format$(Finish - Start, "##.##") & " secs."
- End Sub
-